#ifndef VISTA_INTERIOR_H_
#define VISTA_INTERIOR_H_

#include <cassert>

#include "vista.h"
#include "camlookat.h"
#include "handler.h"
#include "vehiculo.h"
#include "iobmp.h"
#include "textura.h"

class VistaInterior: public Vista {
   private:
      mutable float x,y,z,dx,dy,dz;
      mutable float ux,uy,uz;

      CamLookAt cam;
      Vehiculo &vehiculo;

      Textura *tex;

   public:
      VistaInterior(Handler& handler, Vehiculo &vehiculo) :
         cam(x, y, z, dx, dy, dz, ux, uy, uz), vehiculo(vehiculo), tex(0) {
            cam.configEyeFactor(+1, +1, 0);
            cam.configPointFactor(+3, +3, 0);
            cam.configUpFactor(0.5, 0.5, 1);
            
            Acciones::agregar(handler.signal_specialkey().connect(sigc::mem_fun(vehiculo, &Vehiculo::control)));
         }

      void ver() const {
         vehiculo.posicion(x, y, z, dx, dy, dz);
         vehiculo.direccionArriba(ux, uy, uz);
         cam.ver();
      }

      void dibujar() const {
         assert(false && "NotImplementedError");

         glMatrixMode (GL_PROJECTION);
         glPushMatrix();
         glLoadIdentity ();
         gluOrtho2D(0, 1,0, 1);
         
         glMatrixMode(GL_TEXTURE);
         glPushMatrix();
         glLoadIdentity();

         glMatrixMode(GL_MODELVIEW);
         glPushMatrix();
         glLoadIdentity();
         gluLookAt(0, 0, 0.5, 0, 0, 0, 0, 1, 0);

         glBegin(GL_QUADS);
         glTexCoord2i(0,0);
         glVertex2f(0, 0.3);

         glTexCoord2i(0,1);
         glVertex2f(0, 0);

         glTexCoord2i(1,1);
         glVertex2f(1, 0);

         glTexCoord2i(1,0);
         glVertex2f(1, 0.3);

         glEnd();

         glMatrixMode (GL_PROJECTION);
         glPopMatrix();
         glMatrixMode(GL_TEXTURE);
         glPopMatrix();
         glMatrixMode(GL_MODELVIEW);
         glPopMatrix();
      }

      ~VistaInterior() {
      }
};

#endif
